package com.jackson.config;

/*
 * Author: JacksonCoder
 * FileName: SpringConfig
 * Version: 1.0.0
 */

import org.apache.commons.dbutils.QueryRunner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import javax.sql.DataSource;

@Configuration
@ComponentScan("com.jackson")  // 扫描com.jackson包下的所有组件
@Import(DataSourceConfig.class) // 导入DataSourceConfig类
public class SpringConfig {

    @Bean("queryRunner") // 定义一个名为queryRunner的Bean
    public QueryRunner getQueryRunner(@Autowired DataSource dataSource){

        QueryRunner queryRunner = new QueryRunner(dataSource);  // 创建QueryRunner对象，并传入DataSource
        return  queryRunner;  // 返回QueryRunner对象
    }


}
